---
title: Using Vis Structural Regexes
date: 2018-04-09
footnotes:
- For more comprehensive documentation check out the <a href="http://martanne.github.io/vis/man/vis.1.html">vis man page</a> and also Rob Pike's <a href="http://doc.cat-v.org/bell_labs/structural_regexps/se.pdf">original paper</a> on structural regexes.
---
The [vis editor](https://github.com/martanne/vis) is a great drop-in vim replacement that supports a feature known as structural regexes. The idea of strucutral regexes is best illustrated by example:

```md
one something
two something
unrelated
three something
another
four something
```

In the above snippet, to obtain the selection of lines only containg the word "something", you could use the **x** command as `:x/.*something.*/` on the list, to obtain the selection:

```md
one something
two something
three something
four something
```

Now further, say you only want to match only the remaining lines for `three something`.. You have two options. Either use **x** command again to re-*select* (`:x/.*three.*/`). Or the more interesting alternative is to use the **g** command (`:g/three/`) to *conditionally filter* selections matching the regex. Both results will give you:

```md
three something
```

The **g** command can be thought of as an if-regex-filter-loop and **x** as reselect-regex-loop. Also at your disposal are the **v** and **y** commands which are the inverse of **g** and **x**.